package com.sfh.dog.dialog;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.PopupWindow;

import com.sfh.dog.R;

public class SystemPictureDialog extends PopupWindow
{
	/** 对外回调接口 */
	public interface IPictrue
	{
		/** 拍照 */
		public void takePhoto();
		public void openLib();
	}


	private IPictrue mPictrue;
	public SystemPictureDialog(Context context,IPictrue pictrue)
	{
		super(context);
		this.mPictrue = pictrue;
		init(context);
		
	}


	private void init(Context context)
	{
		View view = LayoutInflater.from(context).inflate(
				R.layout.common_delete_dilaog_view, null);
		view.findViewById(R.id.btChatNow).setOnClickListener(new OnClickListener()
		{
			
			@Override
			public void onClick(View arg0)
			{
				mPictrue.takePhoto();
				dismiss();
			}
		});
		view.findViewById(R.id.btChatPic).setOnClickListener(new OnClickListener()
		{
			
			@Override
			public void onClick(View arg0)
			{
				mPictrue.openLib();
				dismiss();
			}
		});
		view.setFocusableInTouchMode(true);
		this.setFocusable(true);
		this.setContentView(view);
		ColorDrawable colorDrawable = new ColorDrawable(R.color.tan);
		colorDrawable.setAlpha(0);
		this.setBackgroundDrawable(colorDrawable);
		this.setWidth(android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
		this.setHeight(android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
	}


	/**
	 * 显示
	 * 
	 * @param view
	 */
	public void show(View view)
	{
		showAtLocation(view, Gravity.CENTER, 0, 0);
	}
}
